//
//  MSAlertWeaponView.m
//  MagicSword
//
//  Created by Netease on 15/11/19.
//  Copyright © 2015年 Jonear. All rights reserved.
//

#import "MSAlertWeaponView.h"
#import "MSWeaponNode.h"

@implementation MSAlertWeaponView {
    MSWeaponNode *_weaponNode;
    SKLabelNode  *_nameLabel;
    SKLabelNode  *_attackLabel;
    SKSpriteNode *_detailBackgroud;
    SKLabelNode  *_detailLabel;

}

- (id)init {
    self = [super init];
    if (self) {
    }
    
    return self;
}

- (void)setWeaponInfo:(MSWeaponInfo *)info {
    _weaponInfo = info;
    if (!_weaponNode) {
        _weaponNode = [[MSWeaponNode alloc] init];
        _weaponNode.position = CGPointMake(-60, 30);
        _weaponNode.zPosition = 11;
        _weaponNode.size = CGSizeMake(60, 60);
        [_weaponNode setBackgroundHidden:NO];
//        [_weaponNode setCountTitleColor:UIColorFromRGBA(0x1334af, 0.8)];
        [self addChild:_weaponNode];
    }
    [_weaponNode setWeaponInfo:info];
    
    if (!_nameLabel) {
        _nameLabel = [SKLabelNode labelNodeWithFontNamed:@"Helvetica"];
        _nameLabel.position = CGPointMake(35, 35);
        _nameLabel.zPosition = 11;
        _nameLabel.fontSize = 20;
        _nameLabel.fontColor = UIColorFromRGB(0x2f2f30);
        [self addChild:_nameLabel];
    }
    [_nameLabel setText:info.name];
    
    if (!_attackLabel) {
        _attackLabel = [SKLabelNode labelNodeWithFontNamed:@"Helvetica"];
        _attackLabel.position = CGPointMake(35, 8);
        _attackLabel.zPosition = 11;
        _attackLabel.fontSize = 15;
        _attackLabel.fontColor = UIColorFromRGB(0x2f2f30);
        [self addChild:_attackLabel];
    }
    [_attackLabel setText:[NSString stringWithFormat:@"攻击力: %d", info.Attack]];
    
    if (!_detailBackgroud) {
        _detailBackgroud = [SKSpriteNode spriteNodeWithImageNamed:@"main_alert_detail"];
        _detailBackgroud.position = CGPointMake(0, -23);
        _detailBackgroud.zPosition = 11;
        _detailBackgroud.size = CGSizeMake(213, 25);
        [self addChild:_detailBackgroud];
    }
    
    if (!_detailLabel) {
        _detailLabel = [SKLabelNode labelNodeWithFontNamed:@"Helvetica"];
        _detailLabel.position = CGPointMake(0, -28);
        _detailLabel.zPosition = 12;
        _detailLabel.fontSize = 13;
        _detailLabel.fontColor = UIColorFromRGB(0xf25062);
        [self addChild:_detailLabel];
    }
    if (info.detailMsg.length > 0) {
        _detailLabel.fontColor = UIColorFromRGB(0xf25062);
        [_detailLabel setText:info.detailMsg];
    } else {
        _detailLabel.fontColor = [UIColor grayColor];
        [_detailLabel setText:@"无特殊属性"];
    }

}
@end
